#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include <QtDeclarative>

#include <mycallback.h>
#include <mainwindow.h>

#include <hardware/emocap/sbs2emocapdatareader.h>
#include <hardware/emotiv/sbs2emotivdatareader.h>

Q_DECL_EXPORT int main(int argc, char *argv[])
{

    QScopedPointer<QApplication> app(createApplication(argc, argv));

    //set path where recorded data will be stored
    qDebug() << "catalogPath: "<<Sbs2Common::setDefaultCatalogPath();
    //set path where application data is stored
    qDebug() << "rootAppPath: "<<Sbs2Common::setDefaultRootAppPath();

    //create MyCallback object
    MyCallback* myCallback = new MyCallback();
    //create Sbs2DataReader; 0 indicates that we do not overclock N900 (default)
    Sbs2EmotivDataReader* sbs2DataReader = Sbs2EmotivDataReader::New(myCallback,0);


    MainWindow* mw = new MainWindow(myCallback);
    mw->setAttribute(Qt::WA_QuitOnClose);
    mw->show();

    QObject::connect(app.data(), SIGNAL(aboutToQuit()),mw->glwidget,SLOT(quit()));
    QObject::connect(app.data(), SIGNAL(aboutToQuit()), sbs2DataReader, SLOT(aboutToQuit()));
    QObject::connect(app.data(), SIGNAL(aboutToQuit()), mw, SLOT(kill()));
    QObject::connect(myCallback, SIGNAL(cqValue(QString,double)), mw, SLOT(cqValue(QString,double)));
    QObject::connect(mw, SIGNAL(startEegRecording(QString,QString)),myCallback,SLOT(startRecording(QString,QString)));



    return app->exec();
}
